package com.gitee.neuray.security.wb.ribs.controller;

import com.gitee.neuray.security.common.msg.ObjectRestResponse;
import com.gitee.neuray.security.common.msg.TableResultResponse;
import com.gitee.neuray.security.common.util.Query;
import com.gitee.neuray.security.wb.ribs.biz.CyfBiz;
import com.gitee.neuray.security.wb.ribs.vo.CyfVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 报销列表查询
 *
 * @author larksys
 * @email ${email}
 * @date 2020-03-19 14:10:38
 */
@RestController
@RequestMapping("ribs")
public class CyfController {
  @Autowired private CyfBiz cyfBiz;
  /**
   * 获取餐饮费报销信息
   *
   * @param params
   * @return
   */
  @RequestMapping(value = "cyfInfo", method = RequestMethod.GET)
  public TableResultResponse getCyfInfo(@RequestParam Map<String, Object> params) {
    // 查询列表数据
    String ids = "";
    if(params.get("bczt") != null && !"".equals(params.get("bczt"))){
      ids = params.get("bczt").toString();
      String[] idsStrs = ids.split(",");
      params.put("bczt",idsStrs);
    }
    Query query = new Query(params);
    return cyfBiz.getCyfInfo(query);
  }

  /**
   * 填报餐饮费
   *
   * @return
   */
  @RequestMapping(value = "insertCyf", method = RequestMethod.POST)
  public ObjectRestResponse<CyfVo> insertCyf(@RequestBody CyfVo cyfVo) {
    cyfBiz.insertCyf(cyfVo);
    return new ObjectRestResponse<CyfVo>().rel(true);
  }
  /**
   * 餐饮费修改
   *
   * @return
   */
  @RequestMapping(value = "updCyf", method = RequestMethod.PUT)
  public ObjectRestResponse<CyfVo> updCyf(@RequestBody CyfVo cyfVo) {
    cyfBiz.updCyf(cyfVo);
    return new ObjectRestResponse<CyfVo>().rel(true);
  }
  /**
   * 餐饮费删除
   *
   * @return
   */
  @RequestMapping(value = "delCyf/{id}", method = RequestMethod.DELETE)
  public ObjectRestResponse<CyfVo> delCyf(@PathVariable String id) {
    cyfBiz.delCyf(id);
    return new ObjectRestResponse<CyfVo>().rel(true);
  }
}
